package LeetCode.leetcode;

import java.util.ArrayList;
import java.util.List;

/**
 * 杨辉三角2
 * @author: leiwenkang02@meituan.com
 * @date: 2018/8/14
 * @time: 20:03
 */
public class Test119杨辉三角2 {
    public static void main(String[] args) {
        System.out.println(getRow(3));
    }

    public static List<Integer> getRow(int rowIndex) {
        List<Integer> result = new ArrayList<>();
        if (rowIndex < 0) {
            return result;
        }
        if (rowIndex == 0) {
            result.add(1);
            return result;
        }
        List<Integer> before = getRow(rowIndex - 1);
        result.add(1);
        for (int i = 0; i < before.size() - 1; i++) {
            result.add(before.get(i) + before.get(i + 1));
        }
        result.add(1);
        return result;
    }
}
